package sadmin

import (
	"encoding/json"
	"github.com/astaxie/beego"
	"shop/models/sadmin"
)

type UsController struct {
	beego.Controller
}
//@Title usshow
//@Description 展示联系我们信息
//@Success 200 {object} sadmin.Us
//@router /usshow/ [get]
func (c *UsController)UsShow()  {
	com:=sadmin.UsShow()
	c.Ctx.ResponseWriter.WriteHeader(200)
	c.Data["json"]=com
	c.ServeJSON()
}

//@Title Usedit
//@Description 联系我们--编辑
//@Param body body sadmin.Us true "d"
//@Success 200 ok
//@router /us/edit [put]
func (c *UsController)UsEdit()  {
	var com sadmin.Us
	json.Unmarshal(c.Ctx.Input.RequestBody,&com)
	err:=sadmin.UsEdit(com)
	if err!=nil{
		c.Ctx.ResponseWriter.WriteHeader(201)
		c.Data["json"]=err.Error()
	}else {
		c.Ctx.ResponseWriter.WriteHeader(200)
		c.Data["json"]=com
	}
	c.ServeJSON()
}